{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Introduction to atomman: System class\n",
    "\n",
    "__Lucas M. Hale__, [lucas.hale@nist.gov](mailto:lucas.hale@nist.gov?Subject=ipr-demo), _Materials Science and Engineering Division, NIST_.\n",
    "    \n",
    "[Disclaimers](http://www.nist.gov/public_affairs/disclaimer.cfm) "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1. Introduction <a id='section1'></a>\n",
    "\n",
    "The System class represents an atomic system configuration by combining an [Atoms](1.2._Atoms_class.html) object with a [Box](1.1._Box_class.html) object. Additional System methods and attributes deal with boundary conditions and the interaction between the underlying Atoms and Box objects.\n",
    "\n",
    "**NOTE**: The underlying structure of Atoms changed with version 1.2 to be more efficient and easier to work with. Changes have been made to the System class to reflect this."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Library Imports**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "atomman version = 1.4.0\n",
      "Notebook executed on 2021-08-03\n"
     ]
    }
   ],
   "source": [
    "# Standard Python libraries\n",
    "import sys\n",
    "from copy import deepcopy\n",
    "import datetime\n",
    "\n",
    "# http://www.numpy.org/\n",
    "import numpy as np\n",
    "\n",
    "# https://github.com/usnistgov/atomman\n",
    "import atomman as am\n",
    "import atomman.unitconvert as uc\n",
    "\n",
    "# Show atomman version\n",
    "print('atomman version =', am.__version__)\n",
    "\n",
    "# Show date of Notebook execution\n",
    "print('Notebook executed on', datetime.date.today())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2. Basics <a id='section2'></a>\n",
    "\n",
    "### 2.1. Initialization Options\n",
    "\n",
    "Parameters\n",
    "\n",
    "- **atoms** (*atomman.Atoms, optional*) The underlying Atoms object to build system around.\n",
    "\n",
    "- **box** (*atomman.Box, optional*) The underlying box object to build system around.\n",
    "\n",
    "- **pbc** (*tuple or list of bool, optional*) Indicates which of the dimensions related to the three box vectors are periodic.  Default value is (True, True, True).\n",
    "\n",
    "- **scale** (*bool, optional*) If True, atoms.pos will be scaled relative to the box.  Default value is False.\n",
    "\n",
    "- **symbols** (*tuple, optional*) A list of the element symbols for each atom atype.  If len(symbols) is less than natypes, then missing values will be set to None.  Default sets list with all None values.\n",
    "\n",
    "- **masses** (*tuple, optional*) A list of the masses for each atom atype.  If len(symbols) is less than natypes, then missing values will be set to None.  Default sets list with all None values.\n",
    "\n",
    "- **model** (*str or DataModelDict, optional*) File path or content of a JSON/XML data model containing all system information.  Cannot be given with atoms, box or scale.\n",
    "\n",
    "- **safecopy** (*bool, optional*) Flag indicating if values are to be copied before setting.  For values given as objects, direct setting (False, default) may result in the System pointing to the original object.  Using safecopy=True deep copies the objects before setting to avoid this.  Note that safecopy=True may be considerably slower for large numbers of atoms and/or properties.\n",
    "\n",
    "**Note**: Since the number of atoms associated with an Atoms object is constant and a System's Atoms cannot be reassigned, the number of atoms in a System cannot be changed after initialization."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Initialization without parameters uses the default Atoms() and Box() initializers."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "avect =  [ 1.000,  0.000,  0.000]\n",
      "bvect =  [ 0.000,  1.000,  0.000]\n",
      "cvect =  [ 0.000,  0.000,  1.000]\n",
      "origin = [ 0.000,  0.000,  0.000]\n",
      "natoms = 1\n",
      "natypes = 1\n",
      "symbols = (None,)\n",
      "pbc = [ True  True  True]\n",
      "per-atom properties = ['atype', 'pos']\n",
      "     id |   atype |  pos[0] |  pos[1] |  pos[2]\n",
      "      0 |       1 |   0.000 |   0.000 |   0.000\n"
     ]
    }
   ],
   "source": [
    "system = am.System()\n",
    "\n",
    "print(system)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This combination of atoms and box lets you define systems for any unit cell."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "avect =  [ 5.431,  0.000,  0.000]\n",
      "bvect =  [ 0.000,  5.431,  0.000]\n",
      "cvect =  [ 0.000,  0.000,  5.431]\n",
      "origin = [ 0.000,  0.000,  0.000]\n",
      "natoms = 8\n",
      "natypes = 1\n",
      "symbols = ('Si',)\n",
      "pbc = [ True  True  True]\n",
      "per-atom properties = ['atype', 'pos']\n",
      "     id |   atype |  pos[0] |  pos[1] |  pos[2]\n",
      "      0 |       1 |   0.000 |   0.000 |   0.000\n",
      "      1 |       1 |   2.716 |   2.716 |   0.000\n",
      "      2 |       1 |   2.716 |   0.000 |   2.716\n",
      "      3 |       1 |   0.000 |   2.716 |   2.716\n",
      "      4 |       1 |   1.358 |   1.358 |   1.358\n",
      "      5 |       1 |   1.358 |   4.073 |   4.073\n",
      "      6 |       1 |   4.073 |   1.358 |   4.073\n",
      "      7 |       1 |   4.073 |   4.073 |   1.358\n"
     ]
    }
   ],
   "source": [
    "# Define a system for dc Si unit cell\n",
    "pos = np.array([[0.00, 0.00, 0.00],\n",
    "                [0.50, 0.50, 0.00],\n",
    "                [0.50, 0.00, 0.50],\n",
    "                [0.00, 0.50, 0.50],\n",
    "                [0.25, 0.25, 0.25],\n",
    "                [0.25, 0.75, 0.75],\n",
    "                [0.75, 0.25, 0.75],\n",
    "                [0.75, 0.75, 0.25]])\n",
    "atoms = am.Atoms(pos=pos)\n",
    "\n",
    "a = uc.set_in_units(5.431, 'Å')\n",
    "box = am.Box(a=a, b=a, c=a)\n",
    "\n",
    "# Scale = True will unscale atoms.pos to absolute Cartesian coordinates\n",
    "system = am.System(atoms=atoms, box=box, scale=True, symbols='Si')\n",
    "print(system)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3. Built-in Attributes <a id='section3'></a>\n",
    "\n",
    "Each System instance has these built-in attributes:\n",
    "\n",
    "- **atoms** (*atomman.Atoms*) the underlying [Atoms](1.2._Atoms_class.html) object.\n",
    "- **natoms** (*int*) is the number of atoms (same as system.atoms.natoms).\n",
    "- **atypes** (*numpy.ndarray of int*) lists all unique atype values (same as system.atoms.atypes).\n",
    "- **natypes** (*int*) is the number of unique atype values (same as system.atoms.natypes).\n",
    "- **box** (*atomman.Box*) the underlying [Box](1.1._Box_class.html) object.\n",
    "- **pbc** (*numpy.ndarray of bool*) three Boolean values indicating which box directions are periodic.\n",
    "- **symbols** (*tuple*) the element symbols associated with each atype.\n",
    "- **masses** (*tuple*) the masses set for each atype, if needed.  *Added version 1.3.0* \n",
    "- **composition** (*str*) composition description of elements and numbers. *Added version 1.2.7* "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "system.natoms -> 8\n",
      "system.atypes -> (1,)\n",
      "system.natypes -> 1\n",
      "system.symbols -> ('Si',)\n",
      "system.masses -> (None,)\n",
      "system.composition -> Si\n",
      "system.pbc -> [ True  True  True]\n"
     ]
    }
   ],
   "source": [
    "print('system.natoms ->', system.natoms)\n",
    "print('system.atypes ->', system.atypes)\n",
    "print('system.natypes ->', system.natypes)\n",
    "print('system.symbols ->', system.symbols)\n",
    "print('system.masses ->', system.masses)\n",
    "print('system.composition ->', system.composition)\n",
    "print('system.pbc ->', system.pbc)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The pbc values can be set during initialization and changed at any time afterwards."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "setting: system.pbc = [False, True, True]\n",
      "system.pbc -> [False  True  True]\n",
      "\n",
      "setting: system.pbc[0] = True\n",
      "system.pbc -> [ True  True  True]\n"
     ]
    }
   ],
   "source": [
    "print('setting: system.pbc = [False, True, True]')\n",
    "system.pbc = [False, True, True]\n",
    "print('system.pbc ->', system.pbc)\n",
    "print()\n",
    "\n",
    "print('setting: system.pbc[0] = True')\n",
    "system.pbc[0] = True\n",
    "print('system.pbc ->', system.pbc)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The underlying Atoms and Box objects can be directly retrieved.  Note that "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "system.atoms ->\n",
      "per-atom properties = ['atype', 'pos']\n",
      "     id |   atype |  pos[0] |  pos[1] |  pos[2]\n",
      "      0 |       1 |   0.000 |   0.000 |   0.000\n",
      "      1 |       1 |   2.716 |   2.716 |   0.000\n",
      "      2 |       1 |   2.716 |   0.000 |   2.716\n",
      "      3 |       1 |   0.000 |   2.716 |   2.716\n",
      "      4 |       1 |   1.358 |   1.358 |   1.358\n",
      "      5 |       1 |   1.358 |   4.073 |   4.073\n",
      "      6 |       1 |   4.073 |   1.358 |   4.073\n",
      "      7 |       1 |   4.073 |   4.073 |   1.358\n",
      "\n",
      "system.box ->\n",
      "avect =  [ 5.431,  0.000,  0.000]\n",
      "bvect =  [ 0.000,  5.431,  0.000]\n",
      "cvect =  [ 0.000,  0.000,  5.431]\n",
      "origin = [ 0.000,  0.000,  0.000]\n"
     ]
    }
   ],
   "source": [
    "print(\"system.atoms ->\")\n",
    "print(system.atoms)\n",
    "print()\n",
    "\n",
    "print(\"system.box ->\")\n",
    "print(system.box)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Symbols can be updated at any time by supplying a list/tuple. For atype values not associated with a symbol, use None for the symbol.  Note that symbols is stored as a tuple and therefore must all be set at once. \n",
    "\n",
    "*Update 1.3.0* How atypes, natypes, composition and symbols are handled has been changed to allow for mismatches between assigned atype values and symbols lists.  Backwards compatibility will be affected if previous System.atoms had atype values of 0 or non-sequential atype values.\n",
    "\n",
    "- Values for System.atoms.atype are limited to being &ge; 1.\n",
    "- System.atoms.natypes is max(System.atoms.atype)\n",
    "- System.natypes is the greater of System.atoms.natypes or len(System.symbols). \n",
    "- If System.symbols or System.atoms.atype values are changed such that System.atoms.natypes > len(System.symbols), then System.symbols is expanded with None values.\n",
    "- The composition string will be generated if all used atype values are assigned symbols. Otherwise, System.composition will return None."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "setting: system.symbols = ['Si', 'Ge']\n",
      "system.symbols -> ('Ge', 'Si')\n",
      "system.natypes -> 2\n",
      "system.atypes -> (1, 2)\n",
      "\n",
      "CAUTION!\n",
      "system.atoms.natypes -> 1\n",
      "system.atoms.atypes -> (1,)\n"
     ]
    }
   ],
   "source": [
    "# More symbols can be assigned to the system than there are atype values\n",
    "print(\"setting: system.symbols = ['Si', 'Ge']\")\n",
    "system.symbols = ['Ge', 'Si']\n",
    "print('system.symbols ->', system.symbols)\n",
    "\n",
    "# This change is reflected by system.atypes and system.natypes\n",
    "print('system.natypes ->', system.natypes)\n",
    "print('system.atypes ->', system.atypes)\n",
    "\n",
    "# BUT, not by System.atoms.atypes and natypes! They are still based on atype values alone!\n",
    "print('\\nCAUTION!')\n",
    "print('system.atoms.natypes ->', system.atoms.natypes)\n",
    "print('system.atoms.atypes ->', system.atoms.atypes)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "setting: system.symbols = 'Ge'\n",
      "system.symbols -> ('Ge',)\n",
      "system.natypes -> 1\n"
     ]
    }
   ],
   "source": [
    "# Symbols can be reset to remove the extra\n",
    "print(\"setting: system.symbols = 'Ge'\")\n",
    "system.symbols = 'Ge'\n",
    "print('system.symbols ->', system.symbols)\n",
    "print('system.natypes ->', system.natypes)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 4. Scaling Additions <a id='section4'></a>\n",
    "\n",
    "Since atomic positions are stored in absolute Cartesian coordinates, the system has methods for scaling/unscaling vectors relative to the box and which modify methods and attributes of the underlying Atoms and Box classes."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 4.1. scale() and unscale()\n",
    "\n",
    "The scale() and unscale() methods will convert any 3D vectors between the absolute Cartesian and relative box coordinates.\n",
    "\n",
    "- scale() is for absolute Cartesian -> relative box coordinates.\n",
    "- unscale() is for relative box -> absolute Cartesian coordinates."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "setting: spos = system.scale(system.atoms.pos)\n",
      "spos ->\n",
      "[[0.   0.   0.  ]\n",
      " [0.5  0.5  0.  ]\n",
      " [0.5  0.   0.5 ]\n",
      " [0.   0.5  0.5 ]\n",
      " [0.25 0.25 0.25]\n",
      " [0.25 0.75 0.75]\n",
      " [0.75 0.25 0.75]\n",
      " [0.75 0.75 0.25]]\n",
      "\n",
      "setting: pos = system.unscale(spos)\n",
      "pos ->\n",
      "[[0.      0.      0.     ]\n",
      " [2.7155  2.7155  0.     ]\n",
      " [2.7155  0.      2.7155 ]\n",
      " [0.      2.7155  2.7155 ]\n",
      " [1.35775 1.35775 1.35775]\n",
      " [1.35775 4.07325 4.07325]\n",
      " [4.07325 1.35775 4.07325]\n",
      " [4.07325 4.07325 1.35775]]\n"
     ]
    }
   ],
   "source": [
    "# Scale the position vectors\n",
    "print(\"setting: spos = system.scale(system.atoms.pos)\")\n",
    "spos = system.scale(system.atoms.pos)\n",
    "print(\"spos ->\")\n",
    "print(spos)\n",
    "print()\n",
    "\n",
    "# Unscale the scaled position vectors\n",
    "print(\"setting: pos = system.unscale(spos)\")\n",
    "pos = system.unscale(spos)\n",
    "print(\"pos ->\")\n",
    "print(pos)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 4.2. atoms_prop()\n",
    "\n",
    "The atoms_prop() method extends the [atoms.prop()](1.2._Atoms_class.html) method by adding a scale parameter option. \n",
    "\n",
    "- scale=False (default): the property values are returned exactly as they are stored, i.e. this is the same as calling system.atoms.prop(). \n",
    "\n",
    "- scale=True: the property values are automatically scaled/unscaled to/from box relative coordinates. This is convenient as you don't have to remember which scale()/unscale() to use."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Setting: system.atoms_prop(key='pos', index=2, value=[3,3,3])\n",
      "system.atoms.pos[2] ->                     [3. 3. 3.]\n",
      "system.atoms_prop('pos', 2) ->             [3. 3. 3.]\n",
      "system.atoms_prop('pos', 2, scale=True) -> [0.55238446 0.55238446 0.55238446]\n",
      "\n",
      "Setting: system.atoms_prop(key='pos', index=2, value=[0.5,0.0,0.5], scale=True)\n",
      "system.atoms.pos[2] ->                     [2.7155 0.     2.7155]\n",
      "system.atoms_prop('pos', 2) ->             [2.7155 0.     2.7155]\n",
      "system.atoms_prop('pos', 2, scale=True) -> [0.5 0.  0.5]\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# Using atoms_prop() with scale=False is the same as accessing atoms.prop\n",
    "print(\"Setting: system.atoms_prop(key='pos', index=2, value=[3,3,3])\")\n",
    "system.atoms_prop(key='pos', index=2, value=[3,3,3])\n",
    "print(\"system.atoms.pos[2] ->                    \", system.atoms.pos[2])\n",
    "print(\"system.atoms_prop('pos', 2) ->            \", system.atoms_prop('pos', 2))\n",
    "print(\"system.atoms_prop('pos', 2, scale=True) ->\", system.atoms_prop('pos', 2, scale=True))\n",
    "print()\n",
    "\n",
    "# Using atoms_prop(scale=True) properly handles scaling/unscaling\n",
    "print(\"Setting: system.atoms_prop(key='pos', index=2, value=[0.5,0.0,0.5], scale=True)\")\n",
    "system.atoms_prop(key='pos', index=2, value=[0.5,0.0,0.5], scale=True)\n",
    "print(\"system.atoms.pos[2] ->                    \", system.atoms.pos[2])\n",
    "print(\"system.atoms_prop('pos', 2) ->            \", system.atoms_prop('pos', 2))\n",
    "print(\"system.atoms_prop('pos', 2, scale=True) ->\", system.atoms_prop('pos', 2, scale=True))\n",
    "print()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 4.3. atoms_df()\n",
    "\n",
    "The atoms_df() method extends the [atoms.df()](1.2._Atoms_class.html) method with an optional scale parameter. \n",
    "\n",
    "- scale=False (defaut): the property values are returned exactly as they are stored, i.e. this is the same as calling system.atoms.df()\n",
    "\n",
    "- scale=True: the pos values will be scaled to box relative coordinates and all other parameters returned exactly as they are stored.\n",
    "\n",
    "- scale=list of property names: all listed property values will be scaled to box relative coordinates."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>atype</th>\n",
       "      <th>pos[0]</th>\n",
       "      <th>pos[1]</th>\n",
       "      <th>pos[2]</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>0.00000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2.71550</td>\n",
       "      <td>2.71550</td>\n",
       "      <td>0.00000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>2.71550</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>2.71550</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>2.71550</td>\n",
       "      <td>2.71550</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>1.35775</td>\n",
       "      <td>1.35775</td>\n",
       "      <td>1.35775</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "      <td>1.35775</td>\n",
       "      <td>4.07325</td>\n",
       "      <td>4.07325</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>4.07325</td>\n",
       "      <td>1.35775</td>\n",
       "      <td>4.07325</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>7</td>\n",
       "      <td>1</td>\n",
       "      <td>4.07325</td>\n",
       "      <td>4.07325</td>\n",
       "      <td>1.35775</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   atype   pos[0]   pos[1]   pos[2]\n",
       "0      1  0.00000  0.00000  0.00000\n",
       "1      1  2.71550  2.71550  0.00000\n",
       "2      1  2.71550  0.00000  2.71550\n",
       "3      1  0.00000  2.71550  2.71550\n",
       "4      1  1.35775  1.35775  1.35775\n",
       "5      1  1.35775  4.07325  4.07325\n",
       "6      1  4.07325  1.35775  4.07325\n",
       "7      1  4.07325  4.07325  1.35775"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# With scale=False\n",
    "system.atoms_df()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>atype</th>\n",
       "      <th>pos[0]</th>\n",
       "      <th>pos[1]</th>\n",
       "      <th>pos[2]</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.50</td>\n",
       "      <td>0.50</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>0.50</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.50</td>\n",
       "      <td>0.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>0.25</td>\n",
       "      <td>0.25</td>\n",
       "      <td>0.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "      <td>0.25</td>\n",
       "      <td>0.75</td>\n",
       "      <td>0.75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>0.75</td>\n",
       "      <td>0.25</td>\n",
       "      <td>0.75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>7</td>\n",
       "      <td>1</td>\n",
       "      <td>0.75</td>\n",
       "      <td>0.75</td>\n",
       "      <td>0.25</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   atype  pos[0]  pos[1]  pos[2]\n",
       "0      1    0.00    0.00    0.00\n",
       "1      1    0.50    0.50    0.00\n",
       "2      1    0.50    0.00    0.50\n",
       "3      1    0.00    0.50    0.50\n",
       "4      1    0.25    0.25    0.25\n",
       "5      1    0.25    0.75    0.75\n",
       "6      1    0.75    0.25    0.75\n",
       "7      1    0.75    0.75    0.25"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# With scale=True\n",
    "system.atoms_df(scale=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>atype</th>\n",
       "      <th>pos[0]</th>\n",
       "      <th>pos[1]</th>\n",
       "      <th>pos[2]</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.50</td>\n",
       "      <td>0.50</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>0.50</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.50</td>\n",
       "      <td>0.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>0.25</td>\n",
       "      <td>0.25</td>\n",
       "      <td>0.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "      <td>0.25</td>\n",
       "      <td>0.75</td>\n",
       "      <td>0.75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>0.75</td>\n",
       "      <td>0.25</td>\n",
       "      <td>0.75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>7</td>\n",
       "      <td>1</td>\n",
       "      <td>0.75</td>\n",
       "      <td>0.75</td>\n",
       "      <td>0.25</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   atype  pos[0]  pos[1]  pos[2]\n",
       "0      1    0.00    0.00    0.00\n",
       "1      1    0.50    0.50    0.00\n",
       "2      1    0.50    0.00    0.50\n",
       "3      1    0.00    0.50    0.50\n",
       "4      1    0.25    0.25    0.25\n",
       "5      1    0.25    0.75    0.75\n",
       "6      1    0.75    0.25    0.75\n",
       "7      1    0.75    0.75    0.25"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# With scale=['pos']\n",
    "system.atoms_df(scale=['pos'])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 4.4. box_set()\n",
    "\n",
    "The box_set() method extends the [box.set()](1.1._Box_class.html) method to include an optional scale parameter.  This is necessary to define how atomic positions are affected by the change in box dimensions.\n",
    "\n",
    "- scale=False (defaut): the absolute Cartesian coordinates of the atoms are held fixed as the box is changed. This is equivalent to calling box.set() directly.\n",
    "\n",
    "- scale=True: the relative box coordinates of the atoms are held fixed by scaling the Cartesian coordinates as the box is changed.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "avect =  [ 5.658,  0.000,  0.000]\n",
      "bvect =  [ 0.000,  5.658,  0.000]\n",
      "cvect =  [ 0.000,  0.000,  5.658]\n",
      "origin = [ 0.000,  0.000,  0.000]\n",
      "natoms = 8\n",
      "natypes = 1\n",
      "symbols = ('Ge',)\n",
      "pbc = [ True  True  True]\n",
      "per-atom properties = ['atype', 'pos']\n",
      "     id |   atype |  pos[0] |  pos[1] |  pos[2]\n",
      "      0 |       1 |   0.000 |   0.000 |   0.000\n",
      "      1 |       1 |   2.716 |   2.716 |   0.000\n",
      "      2 |       1 |   2.716 |   0.000 |   2.716\n",
      "      3 |       1 |   0.000 |   2.716 |   2.716\n",
      "      4 |       1 |   1.358 |   1.358 |   1.358\n",
      "      5 |       1 |   1.358 |   4.073 |   4.073\n",
      "      6 |       1 |   4.073 |   1.358 |   4.073\n",
      "      7 |       1 |   4.073 |   4.073 |   1.358\n",
      "\n",
      "system.atoms_prop('pos', scale=True) =\n",
      "[[0.         0.         0.        ]\n",
      " [0.47993991 0.47993991 0.        ]\n",
      " [0.47993991 0.         0.47993991]\n",
      " [0.         0.47993991 0.47993991]\n",
      " [0.23996995 0.23996995 0.23996995]\n",
      " [0.23996995 0.71990986 0.71990986]\n",
      " [0.71990986 0.23996995 0.71990986]\n",
      " [0.71990986 0.71990986 0.23996995]]\n"
     ]
    }
   ],
   "source": [
    "# With scale=False, Cartesian coordinates are unchanged,\n",
    "newa = uc.set_in_units(5.658, 'Å')\n",
    "system.box_set(a=newa, b=newa, c=newa)\n",
    "print(system)\n",
    "print()\n",
    "\n",
    "# while box relative coordinates are changed\n",
    "print(\"system.atoms_prop('pos', scale=True) =\")\n",
    "print(system.atoms_prop('pos', scale=True))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "avect =  [ 5.658,  0.000,  0.000]\n",
      "bvect =  [ 0.000,  5.658,  0.000]\n",
      "cvect =  [ 0.000,  0.000,  5.658]\n",
      "origin = [ 0.000,  0.000,  0.000]\n",
      "natoms = 8\n",
      "natypes = 1\n",
      "symbols = ('Ge',)\n",
      "pbc = [ True  True  True]\n",
      "per-atom properties = ['atype', 'pos']\n",
      "     id |   atype |  pos[0] |  pos[1] |  pos[2]\n",
      "      0 |       1 |   0.000 |   0.000 |   0.000\n",
      "      1 |       1 |   2.829 |   2.829 |   0.000\n",
      "      2 |       1 |   2.829 |   0.000 |   2.829\n",
      "      3 |       1 |   0.000 |   2.829 |   2.829\n",
      "      4 |       1 |   1.414 |   1.414 |   1.414\n",
      "      5 |       1 |   1.414 |   4.244 |   4.244\n",
      "      6 |       1 |   4.244 |   1.414 |   4.244\n",
      "      7 |       1 |   4.244 |   4.244 |   1.414\n",
      "\n",
      "system.atoms_prop('pos', scale=True) =\n",
      "[[0.   0.   0.  ]\n",
      " [0.5  0.5  0.  ]\n",
      " [0.5  0.   0.5 ]\n",
      " [0.   0.5  0.5 ]\n",
      " [0.25 0.25 0.25]\n",
      " [0.25 0.75 0.75]\n",
      " [0.75 0.25 0.75]\n",
      " [0.75 0.75 0.25]]\n"
     ]
    }
   ],
   "source": [
    "# Return to original box\n",
    "system.box_set(a=a, b=a, c=a)\n",
    "\n",
    "# With scale=True, Cartesian coordinates change,\n",
    "system.box_set(a=newa, b=newa, c=newa, scale=True)\n",
    "print(system)\n",
    "print()\n",
    "\n",
    "# while box relative coordinates are unchanged.\n",
    "print(\"system.atoms_prop('pos', scale=True) =\")\n",
    "print(system.atoms_prop('pos', scale=True))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 5. Built-in manipulations <a id='section5'></a>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 5.1. wrap()\n",
    "\n",
    "The wrap method adjusts the atoms and box to ensure that all atomic positions are contained within the box.  For atoms with positions beyond the box boundaries:\n",
    "\n",
    "- If the boundary condition is periodic (as defined in pbc) then the atom's position is folded to an equivalent position within the boundaries for that dimension.\n",
    "- If the boundary condition is non-periodic, the boundary is adjusted to encompass the atom."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "avect =  [ 1.000,  0.000,  0.000]\n",
      "bvect =  [ 0.000,  1.000,  0.000]\n",
      "cvect =  [ 0.000,  0.000,  1.000]\n",
      "origin = [ 0.000,  0.000,  0.000]\n",
      "natoms = 10\n",
      "natypes = 1\n",
      "symbols = (None,)\n",
      "pbc = [ True  True  True]\n",
      "per-atom properties = ['atype', 'pos']\n",
      "     id |   atype |  pos[0] |  pos[1] |  pos[2]\n",
      "      0 |       1 |   3.162 |   6.211 |   1.950\n",
      "      1 |       1 |   8.674 |   0.559 |   7.718\n",
      "      2 |       1 |   7.439 |   0.502 |   8.636\n",
      "      3 |       1 |   5.279 |   9.833 |   1.349\n",
      "      4 |       1 |   4.218 |   1.356 |   2.301\n",
      "      5 |       1 |   8.616 |   3.619 |   5.798\n",
      "      6 |       1 |   0.905 |   8.565 |   8.355\n",
      "      7 |       1 |   9.889 |   5.258 |   3.850\n",
      "      8 |       1 |   8.874 |   5.331 |   1.700\n",
      "      9 |       1 |   6.707 |   4.164 |   4.582\n"
     ]
    }
   ],
   "source": [
    "# Generate ten atom system with atoms between 0 and 10 and box boundaries 0 and 1\n",
    "system = am.System(atoms=am.Atoms(pos=10*np.random.rand(10,3)))\n",
    "print(system)   "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Atoms are wrapped around periodic boundaries, and non-periodic boundaries are extended to encompass all atoms."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "avect =  [ 1.000,  0.000,  0.000]\n",
      "bvect =  [ 0.000,  9.834,  0.000]\n",
      "cvect =  [ 0.000,  0.000,  1.000]\n",
      "origin = [ 0.000,  0.000,  0.000]\n",
      "natoms = 10\n",
      "natypes = 1\n",
      "symbols = (None,)\n",
      "pbc = [ True False  True]\n",
      "per-atom properties = ['atype', 'pos']\n",
      "     id |   atype |  pos[0] |  pos[1] |  pos[2]\n",
      "      0 |       1 |   0.162 |   6.211 |   0.950\n",
      "      1 |       1 |   0.674 |   0.559 |   0.718\n",
      "      2 |       1 |   0.439 |   0.502 |   0.636\n",
      "      3 |       1 |   0.279 |   9.833 |   0.349\n",
      "      4 |       1 |   0.218 |   1.356 |   0.301\n",
      "      5 |       1 |   0.616 |   3.619 |   0.798\n",
      "      6 |       1 |   0.905 |   8.565 |   0.355\n",
      "      7 |       1 |   0.889 |   5.258 |   0.850\n",
      "      8 |       1 |   0.874 |   5.331 |   0.700\n",
      "      9 |       1 |   0.707 |   4.164 |   0.582\n"
     ]
    }
   ],
   "source": [
    "# Simple example with mixed periodic and non-periodic boundaries\n",
    "system.pbc = (True, False, True)\n",
    "system.wrap()\n",
    "print(system)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 5.2. normalize()\n",
    "\n",
    "The box vectors for a system may not be compatible with certain codes, such as LAMMPS.  The normalize() method helps with this by converting incompatible systems to a compatible representation.\n",
    "\n",
    "Parameters\n",
    "\n",
    "- **style** (*str, optional*) Indicates the normalization style to use.  Default (and only current option) is 'lammps'.\n",
    "- **return_transform** (*bool, optional*) Indicates if the transformation matrix associated with the normalization is to be returned.  Default value is False.\n",
    "\n",
    "For style='lammps', the system is altered so that the returned system has:\n",
    "\n",
    "1. Right-handed box vectors.\n",
    "\n",
    "2. avect = [lx, 0.0, 0.0]\n",
    "\n",
    "3. bvect = [xy, ly,  0.0]\n",
    "\n",
    "4. cvect = [xz, yz,  lz]\n",
    "\n",
    "5. All atoms initially inside the box dimensions.\n",
    "\n",
    "**Note**: large box tilt factors are not adjusted with this function. As such, the LAMMPS command 'box tilt large' may be needed."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "avect =  [ 0.248,  0.204,  0.796]\n",
      "bvect =  [ 0.435,  0.660,  0.796]\n",
      "cvect =  [ 0.188,  0.630,  0.385]\n",
      "origin = [ 0.000,  0.000,  0.000]\n",
      "natoms = 2\n",
      "natypes = 1\n",
      "symbols = (None,)\n",
      "pbc = [ True  True  True]\n",
      "per-atom properties = ['atype', 'pos']\n",
      "     id |   atype |  pos[0] |  pos[1] |  pos[2]\n",
      "      0 |       1 |   0.000 |   0.000 |   0.000\n",
      "      1 |       1 |   0.436 |   0.747 |   0.989\n",
      "a = 0.8586100772316914\n",
      "b = 1.1218347608798915\n",
      "c = 0.7625630034164564\n",
      "alpha = 19.804354324501812\n",
      "beta = 42.54725061072815\n",
      "gamma = 24.513806827840508\n"
     ]
    }
   ],
   "source": [
    "# Define a system with random box vectors\n",
    "box = am.Box(vects=np.random.rand(3,3))\n",
    "atoms = am.Atoms(pos=[[0.0, 0.0, 0.0], [0.5, 0.5, 0.5]])\n",
    "system = am.System(atoms=atoms, box=box, scale=True)\n",
    "print(system)\n",
    "print('a =', system.box.a)\n",
    "print('b =', system.box.b)\n",
    "print('c =', system.box.c)\n",
    "print('alpha =', system.box.alpha)\n",
    "print('beta =', system.box.beta)\n",
    "print('gamma =', system.box.gamma)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "avect =  [ 0.859,  0.000,  0.000]\n",
      "bvect =  [ 1.021,  0.465,  0.000]\n",
      "cvect =  [ 0.562,  0.497,  0.137]\n",
      "origin = [ 0.000,  0.000,  0.000]\n",
      "natoms = 2\n",
      "natypes = 1\n",
      "symbols = (None,)\n",
      "pbc = [ True  True  True]\n",
      "per-atom properties = ['atype', 'pos']\n",
      "     id |   atype |  pos[0] |  pos[1] |  pos[2]\n",
      "      0 |       1 |   0.000 |   0.000 |   0.000\n",
      "      1 |       1 |   1.221 |   0.481 |   0.068\n",
      "a = 0.8586100772316914\n",
      "b = 1.1218347608798915\n",
      "c = 0.7625630034164564\n",
      "alpha = 19.804354324501798\n",
      "beta = 42.54725061072814\n",
      "gamma = 24.513806827840494\n",
      "Box relative positions:\n",
      "[[0.  0.  0. ]\n",
      " [0.5 0.5 0.5]]\n"
     ]
    }
   ],
   "source": [
    "# Normalize box and show that lattice parameters and box relative positions are unchanged\n",
    "system = system.normalize()\n",
    "print(system)\n",
    "print('a =', system.box.a)\n",
    "print('b =', system.box.b)\n",
    "print('c =', system.box.c)\n",
    "print('alpha =', system.box.alpha)\n",
    "print('beta =', system.box.beta)\n",
    "print('gamma =', system.box.gamma)\n",
    "print('Box relative positions:')\n",
    "print(system.atoms_prop(key='pos', scale=True))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 5.3. rotate()\n",
    "\n",
    "The System class also has a built-in rotate() method that can be used to rotate the system to a new orientation.  The rotated system will be expanded to retain periodicity across its boundaries.\n",
    "\n",
    "Parameters\n",
    "\n",
    "- **uvws** (*array-like object*) 3x3 array of three [uvw] Miller crystal vectors or 3x4 array of three [uvtw] Miller-Bravais hexagonal crystal vectors relative to the original system. These must define full Miller vectors, i.e. all u, v, w values be integers. These crystal vectors will align with the rotated system's box vectors.\n",
    "\n",
    "- **tol** (*float, optional*) Tolerance parameter used in rounding atomic positions near the boundaries to the boundary values.  In box-relative coordinates, any atomic positions within tol of 0 or 1 will be rounded to 0 or 1, respectively.  Default value is 1e-5.\n",
    "\n",
    "- **return_transform** (*bool, optional*) Indicates if the transformation matrix associated with the normalization is to be returned.  Default value is False.\n",
    "\n",
    "Returns\n",
    "\n",
    "- **newsystem** (*atomman.System*) a new System based on rotating and expanding the original.\n",
    "\n",
    "- **transform** (*numpy.ndarray*) the transformation matrix associated with the rotation.  Returned if return_transform is True."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "avect =  [ 3.030,  0.000,  0.000]\n",
      "bvect =  [ 0.000,  3.030,  0.000]\n",
      "cvect =  [ 0.000,  0.000,  3.030]\n",
      "origin = [ 0.000,  0.000,  0.000]\n",
      "natoms = 2\n",
      "natypes = 1\n",
      "symbols = ('V',)\n",
      "pbc = [ True  True  True]\n",
      "per-atom properties = ['atype', 'pos']\n",
      "     id |   atype |  pos[0] |  pos[1] |  pos[2]\n",
      "      0 |       1 |   0.000 |   0.000 |   0.000\n",
      "      1 |       1 |   1.515 |   1.515 |   1.515\n"
     ]
    }
   ],
   "source": [
    "# Define a bcc unit cell for vanadium\n",
    "alat = uc.set_in_units(3.03, 'Å')\n",
    "box = am.Box(a=alat, b=alat, c=alat)\n",
    "atoms = am.Atoms(pos=[[0.0, 0.0, 0.0], [0.5, 0.5, 0.5]])\n",
    "system = am.System(atoms=atoms, box=box, scale=True, symbols='V')\n",
    "\n",
    "print(system)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Rotated system:\n",
      "avect =  [ 7.422,  0.000,  0.000]\n",
      "bvect =  [ 0.000,  5.248,  0.000]\n",
      "cvect =  [ 0.000,  0.000,  4.285]\n",
      "origin = [ 0.000,  0.000,  0.000]\n",
      "natoms = 12\n",
      "natypes = 1\n",
      "symbols = ('V',)\n",
      "pbc = [ True  True  True]\n",
      "per-atom properties = ['atype', 'pos']\n",
      "     id |   atype |  pos[0] |  pos[1] |  pos[2]\n",
      "      0 |       1 |   6.185 |   0.875 |   2.143\n",
      "      1 |       1 |   2.474 |   0.875 |   4.285\n",
      "      2 |       1 |   3.711 |   0.000 |   2.143\n",
      "      3 |       1 |   3.711 |   2.624 |   2.143\n",
      "      4 |       1 |   4.948 |   1.749 |   4.285\n",
      "      5 |       1 |   4.948 |   4.373 |   4.285\n",
      "      6 |       1 |   6.185 |   3.499 |   2.143\n",
      "      7 |       1 |   0.000 |   0.000 |   0.000\n",
      "      8 |       1 |   7.422 |   2.624 |   4.285\n",
      "      9 |       1 |   1.237 |   1.749 |   2.143\n",
      "     10 |       1 |   1.237 |   4.373 |   2.143\n",
      "     11 |       1 |   2.474 |   3.499 |   4.285\n",
      "\n",
      "Transformation matrix:\n",
      "[[ 4.08248290e-01  4.08248290e-01 -8.16496581e-01]\n",
      " [ 5.77350269e-01  5.77350269e-01  5.77350269e-01]\n",
      " [ 7.07106781e-01 -7.07106781e-01  2.74677003e-16]]\n"
     ]
    }
   ],
   "source": [
    "# Rotate the system to coincide with the following crystal vectors\n",
    "a_uvw = [ 1, 1,-2]\n",
    "b_uvw = [ 1, 1, 1]\n",
    "c_uvw = [ 1,-1, 0]\n",
    "\n",
    "system, transform = system.rotate([a_uvw, b_uvw, c_uvw], return_transform=True)\n",
    "\n",
    "print('Rotated system:')\n",
    "print(system)\n",
    "print()\n",
    "print('Transformation matrix:')\n",
    "print(transform)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 5.4. supersize()\n",
    "\n",
    "A supercell version of a system can be generated using the supersize() method.\n",
    "\n",
    "Parameters\n",
    "\n",
    "- **a_size** (*int or tuple of int*) size multipliers for the system along the a box vector.\n",
    "\n",
    "- **b_size** (*int or tuple of int*) size multipliers for the system along the b box vector.\n",
    "\n",
    "- **c_size** (*int or tuple of int*) size multipliers for the system along the c box vector.\n",
    "\n",
    "Returns\n",
    "\n",
    "- (*atomman.System*) a new System constructed by replicating the original along its box vectors.\n",
    "\n",
    "All three size terms can be positive or negative integers, or a tuple of (negative, positive) integers. Negative values replicate the system below the origin and positive values replicate the system above the origin."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "avect =  [14.844,  0.000,  0.000]\n",
      "bvect =  [ 0.000, 10.496,  0.000]\n",
      "cvect =  [ 0.000,  0.000,  8.570]\n",
      "origin = [ 0.000, -10.496, -4.285]\n",
      "natoms = 96\n",
      "natypes = 1\n",
      "symbols = ('V',)\n",
      "pbc = [ True  True  True]\n",
      "per-atom properties = ['atype', 'pos']\n",
      "     id |   atype |  pos[0] |  pos[1] |  pos[2]\n",
      "      0 |       1 |   6.185 |  -9.622 |  -2.143\n",
      "      1 |       1 |   2.474 |  -9.622 |  -0.000\n",
      "      2 |       1 |   3.711 | -10.496 |  -2.143\n",
      "      3 |       1 |   3.711 |  -7.872 |  -2.143\n",
      "      4 |       1 |   4.948 |  -8.747 |  -0.000\n",
      "      5 |       1 |   4.948 |  -6.123 |  -0.000\n",
      "      6 |       1 |   6.185 |  -6.997 |  -2.143\n",
      "      7 |       1 |   0.000 | -10.496 |  -4.285\n",
      "      8 |       1 |   7.422 |  -7.872 |  -0.000\n",
      "      9 |       1 |   1.237 |  -8.747 |  -2.143\n",
      "     10 |       1 |   1.237 |  -6.123 |  -2.143\n",
      "     11 |       1 |   2.474 |  -6.997 |   0.000\n",
      "     12 |       1 |  13.607 |  -9.622 |  -2.143\n",
      "     13 |       1 |   9.896 |  -9.622 |  -0.000\n",
      "     14 |       1 |  11.133 | -10.496 |  -2.143\n",
      "     15 |       1 |  11.133 |  -7.872 |  -2.143\n",
      "     16 |       1 |  12.370 |  -8.747 |  -0.000\n",
      "     17 |       1 |  12.370 |  -6.123 |  -0.000\n",
      "     18 |       1 |  13.607 |  -6.997 |  -2.143\n",
      "     19 |       1 |   7.422 | -10.496 |  -4.285\n",
      "     20 |       1 |  14.844 |  -7.872 |  -0.000\n",
      "     21 |       1 |   8.659 |  -8.747 |  -2.143\n",
      "     22 |       1 |   8.659 |  -6.123 |  -2.143\n",
      "     23 |       1 |   9.896 |  -6.997 |   0.000\n",
      "     24 |       1 |   6.185 |  -4.373 |  -2.143\n",
      "     25 |       1 |   2.474 |  -4.373 |  -0.000\n",
      "     26 |       1 |   3.711 |  -5.248 |  -2.143\n",
      "     27 |       1 |   3.711 |  -2.624 |  -2.143\n",
      "     28 |       1 |   4.948 |  -3.499 |  -0.000\n",
      "     29 |       1 |   4.948 |  -0.875 |  -0.000\n",
      "     30 |       1 |   6.185 |  -1.749 |  -2.143\n",
      "     31 |       1 |   0.000 |  -5.248 |  -4.285\n",
      "     32 |       1 |   7.422 |  -2.624 |  -0.000\n",
      "     33 |       1 |   1.237 |  -3.499 |  -2.143\n",
      "     34 |       1 |   1.237 |  -0.875 |  -2.143\n",
      "     35 |       1 |   2.474 |  -1.749 |   0.000\n",
      "     36 |       1 |  13.607 |  -4.373 |  -2.143\n",
      "     37 |       1 |   9.896 |  -4.373 |  -0.000\n",
      "     38 |       1 |  11.133 |  -5.248 |  -2.143\n",
      "     39 |       1 |  11.133 |  -2.624 |  -2.143\n",
      "     40 |       1 |  12.370 |  -3.499 |  -0.000\n",
      "     41 |       1 |  12.370 |  -0.875 |  -0.000\n",
      "     42 |       1 |  13.607 |  -1.749 |  -2.143\n",
      "     43 |       1 |   7.422 |  -5.248 |  -4.285\n",
      "     44 |       1 |  14.844 |  -2.624 |  -0.000\n",
      "     45 |       1 |   8.659 |  -3.499 |  -2.143\n",
      "     46 |       1 |   8.659 |  -0.875 |  -2.143\n",
      "     47 |       1 |   9.896 |  -1.749 |   0.000\n",
      "     48 |       1 |   6.185 |  -9.622 |   2.143\n",
      "     49 |       1 |   2.474 |  -9.622 |   4.285\n",
      "     50 |       1 |   3.711 | -10.496 |   2.143\n",
      "     51 |       1 |   3.711 |  -7.872 |   2.143\n",
      "     52 |       1 |   4.948 |  -8.747 |   4.285\n",
      "     53 |       1 |   4.948 |  -6.123 |   4.285\n",
      "     54 |       1 |   6.185 |  -6.997 |   2.143\n",
      "     55 |       1 |   0.000 | -10.496 |   0.000\n",
      "     56 |       1 |   7.422 |  -7.872 |   4.285\n",
      "     57 |       1 |   1.237 |  -8.747 |   2.143\n",
      "     58 |       1 |   1.237 |  -6.123 |   2.143\n",
      "     59 |       1 |   2.474 |  -6.997 |   4.285\n",
      "     60 |       1 |  13.607 |  -9.622 |   2.143\n",
      "     61 |       1 |   9.896 |  -9.622 |   4.285\n",
      "     62 |       1 |  11.133 | -10.496 |   2.143\n",
      "     63 |       1 |  11.133 |  -7.872 |   2.143\n",
      "     64 |       1 |  12.370 |  -8.747 |   4.285\n",
      "     65 |       1 |  12.370 |  -6.123 |   4.285\n",
      "     66 |       1 |  13.607 |  -6.997 |   2.143\n",
      "     67 |       1 |   7.422 | -10.496 |   0.000\n",
      "     68 |       1 |  14.844 |  -7.872 |   4.285\n",
      "     69 |       1 |   8.659 |  -8.747 |   2.143\n",
      "     70 |       1 |   8.659 |  -6.123 |   2.143\n",
      "     71 |       1 |   9.896 |  -6.997 |   4.285\n",
      "     72 |       1 |   6.185 |  -4.373 |   2.143\n",
      "     73 |       1 |   2.474 |  -4.373 |   4.285\n",
      "     74 |       1 |   3.711 |  -5.248 |   2.143\n",
      "     75 |       1 |   3.711 |  -2.624 |   2.143\n",
      "     76 |       1 |   4.948 |  -3.499 |   4.285\n",
      "     77 |       1 |   4.948 |  -0.875 |   4.285\n",
      "     78 |       1 |   6.185 |  -1.749 |   2.143\n",
      "     79 |       1 |   0.000 |  -5.248 |   0.000\n",
      "     80 |       1 |   7.422 |  -2.624 |   4.285\n",
      "     81 |       1 |   1.237 |  -3.499 |   2.143\n",
      "     82 |       1 |   1.237 |  -0.875 |   2.143\n",
      "     83 |       1 |   2.474 |  -1.749 |   4.285\n",
      "     84 |       1 |  13.607 |  -4.373 |   2.143\n",
      "     85 |       1 |   9.896 |  -4.373 |   4.285\n",
      "     86 |       1 |  11.133 |  -5.248 |   2.143\n",
      "     87 |       1 |  11.133 |  -2.624 |   2.143\n",
      "     88 |       1 |  12.370 |  -3.499 |   4.285\n",
      "     89 |       1 |  12.370 |  -0.875 |   4.285\n",
      "     90 |       1 |  13.607 |  -1.749 |   2.143\n",
      "     91 |       1 |   7.422 |  -5.248 |   0.000\n",
      "     92 |       1 |  14.844 |  -2.624 |   4.285\n",
      "     93 |       1 |   8.659 |  -3.499 |   2.143\n",
      "     94 |       1 |   8.659 |  -0.875 |   2.143\n",
      "     95 |       1 |   9.896 |  -1.749 |   4.285\n"
     ]
    }
   ],
   "source": [
    "# Create 2x2x2 supercell\n",
    "# new avect will start at the old origin\n",
    "a_size = 2\n",
    "\n",
    "# new bvect will end at the old origin\n",
    "b_size = -2\n",
    "\n",
    "# new cvect will be centered around the old origin\n",
    "c_size =(-1,1)\n",
    "\n",
    "system = system.supersize(a_size, b_size, c_size)\n",
    "\n",
    "print(system)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 5.5. atoms_ix\n",
    "\n",
    "*Added version 1.2.5*\n",
    "\n",
    "The atoms_ix extends the indexing functionality of the Atoms class to operate at the System level. This allows for systems containing a subset of the atoms to be easily generated."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "per-atom properties = ['atype', 'pos']\n",
      "     id |   atype |  pos[0] |  pos[1] |  pos[2]\n",
      "      0 |       1 |   2.474 |  -9.622 |  -0.000\n",
      "      1 |       1 |   3.711 | -10.496 |  -2.143\n",
      "      2 |       1 |   0.000 | -10.496 |  -4.285\n",
      "      3 |       1 |   7.422 |  -7.872 |  -0.000\n"
     ]
    }
   ],
   "source": [
    "# Indexing directly on the system's atoms returns a new Atoms object\n",
    "subatoms = system.atoms[[1,2,7,8]]\n",
    "print(subatoms)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "avect =  [14.844,  0.000,  0.000]\n",
      "bvect =  [ 0.000, 10.496,  0.000]\n",
      "cvect =  [ 0.000,  0.000,  8.570]\n",
      "origin = [ 0.000, -10.496, -4.285]\n",
      "natoms = 4\n",
      "natypes = 1\n",
      "symbols = ('V',)\n",
      "pbc = [ True  True  True]\n",
      "per-atom properties = ['atype', 'pos']\n",
      "     id |   atype |  pos[0] |  pos[1] |  pos[2]\n",
      "      0 |       1 |   2.474 |  -9.622 |  -0.000\n",
      "      1 |       1 |   3.711 | -10.496 |  -2.143\n",
      "      2 |       1 |   0.000 | -10.496 |  -4.285\n",
      "      3 |       1 |   7.422 |  -7.872 |  -0.000\n"
     ]
    }
   ],
   "source": [
    "# Using atoms_ix will return a new System containing the specified subset of atoms\n",
    "subsystem = system.atoms_ix[[1,2,7,8]]\n",
    "print(subsystem)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Also, atoms_ix can be used to set (i.e. copy) a subset of atoms by passing in either a compatible Atoms or System object. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "avect =  [14.844,  0.000,  0.000]\n",
      "bvect =  [ 0.000, 10.496,  0.000]\n",
      "cvect =  [ 0.000,  0.000,  8.570]\n",
      "origin = [ 0.000, -10.496, -4.285]\n",
      "natoms = 4\n",
      "natypes = 1\n",
      "symbols = ('V',)\n",
      "pbc = [ True  True  True]\n",
      "per-atom properties = ['atype', 'pos']\n",
      "     id |   atype |  pos[0] |  pos[1] |  pos[2]\n",
      "      0 |       1 |   2.474 |  -9.622 |  -0.000\n",
      "      1 |       1 |   2.474 |  -9.622 |  -0.000\n",
      "      2 |       1 |   2.474 |  -9.622 |  -0.000\n",
      "      3 |       1 |   7.422 |  -7.872 |  -0.000\n"
     ]
    }
   ],
   "source": [
    "# Copy atom 0 to atom 1 by passing a compatible Atoms object\n",
    "subsystem.atoms_ix[1] = subsystem.atoms[0] \n",
    "\n",
    "# Copy atom 0 to atom 2 by passing a compatible System object\n",
    "subsystem.atoms_ix[2] = subsystem.atoms_ix[0] \n",
    "\n",
    "print(subsystem)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 5.6. atoms_extend()\n",
    "\n",
    "*Added version 1.2.8*\n",
    "\n",
    "The atoms_extend() method allows the extend() method of the Atoms class to operate at the System level. This allows for new Systems to be generated by copying the current System object with additional atoms.\n",
    "        \n",
    "Parameters\n",
    "- __value__ (*atomman.Atoms or int*) An int value will result in the atoms object being extended by that number of atoms, with all per-atom properties having default values (atype = 1, everything else = 0).  For an Atoms value, the current atoms list will be extended by the correct number of atoms and all per-atom properties in value will be copied over.  Any properties defined in one Atoms object and not the other will be set to default values.\n",
    "- __scale__ (*bool, optional*) Flag indicating if position values in a supplied Atoms value are to be taken as absolute Cartesian (False, default) or in scaled box relative units (True).\n",
    "- __symbols__ (*tuple, list or None, optional*) Allows for the system's symbols list to be updated.  If not given, will use the current object's symbols.\n",
    "- __safecopy__ (*bool, optional*) Flag indicating if values are to be copied before setting.  If False (default), underlying objects may be shared between the new system and the current system and input parameters.  If True, atoms and box will be deepcopied before setting. Note that safecopy=True may be considerably slower for large numbers of atoms and/or properties.\n",
    "\n",
    "Returns\n",
    "- (*atomman.System*) A new System object with Atoms extended to contain all atoms and properties of the current object plus the additional atoms.  The cuurent System object's box and pbc (and symbols if not specified) will be copied over."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "avect =  [14.844,  0.000,  0.000]\n",
      "bvect =  [ 0.000, 10.496,  0.000]\n",
      "cvect =  [ 0.000,  0.000,  8.570]\n",
      "origin = [ 0.000, -10.496, -4.285]\n",
      "natoms = 6\n",
      "natypes = 1\n",
      "symbols = ('V',)\n",
      "pbc = [ True  True  True]\n",
      "per-atom properties = ['atype', 'pos']\n",
      "     id |   atype |  pos[0] |  pos[1] |  pos[2]\n",
      "      0 |       1 |   2.474 |  -9.622 |  -0.000\n",
      "      1 |       1 |   2.474 |  -9.622 |  -0.000\n",
      "      2 |       1 |   2.474 |  -9.622 |  -0.000\n",
      "      3 |       1 |   7.422 |  -7.872 |  -0.000\n",
      "      4 |       1 |   0.000 |   0.000 |   0.000\n",
      "      5 |       1 |   0.000 |   0.000 |   0.000\n"
     ]
    }
   ],
   "source": [
    "# Add two empty atoms to subsystem\n",
    "print(subsystem.atoms_extend(2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "avect =  [14.844,  0.000,  0.000]\n",
      "bvect =  [ 0.000, 10.496,  0.000]\n",
      "cvect =  [ 0.000,  0.000,  8.570]\n",
      "origin = [ 0.000, -10.496, -4.285]\n",
      "natoms = 8\n",
      "natypes = 1\n",
      "symbols = ('V',)\n",
      "pbc = [ True  True  True]\n",
      "per-atom properties = ['atype', 'pos']\n",
      "     id |   atype |  pos[0] |  pos[1] |  pos[2]\n",
      "      0 |       1 |   2.474 |  -9.622 |  -0.000\n",
      "      1 |       1 |   2.474 |  -9.622 |  -0.000\n",
      "      2 |       1 |   2.474 |  -9.622 |  -0.000\n",
      "      3 |       1 |   7.422 |  -7.872 |  -0.000\n",
      "      4 |       1 |   2.474 |  -9.622 |  -0.000\n",
      "      5 |       1 |   2.474 |  -9.622 |  -0.000\n",
      "      6 |       1 |   2.474 |  -9.622 |  -0.000\n",
      "      7 |       1 |   7.422 |  -7.872 |  -0.000\n"
     ]
    }
   ],
   "source": [
    "# double the atoms in subsystem by copying them\n",
    "print(subsystem.atoms_extend(subsystem.atoms))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 6. Built-in analysis tools <a id='section6'></a>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 6.1. dvect() and dmag()\n",
    "\n",
    "The dvect() and dmag() methods calculate the shortest vector difference between two positions, accounting for the system's periodic boundaries. dvect returns the vector(s), while dmag returns the magnitudes of the vectors.\n",
    "\n",
    "Parameters\n",
    "\n",
    "- **pos_0** (*numpy.ndarray or index*) Absolute Cartesian vector position(s) to use as reference point(s).  If the value can be used as an index, then self.atoms.pos\\[pos_0\\] is taken.\n",
    "\n",
    "- **pos_1** (*numpy.ndarray or index*) Absolute Cartesian vector position(s) to find relative to pos_0. If the value can be used as an index, then self.atoms.pos\\[pos_1\\] is taken."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "system.atoms.pos[7] - system.atoms.pos[12] ->\n",
      "[-13.60691552  -0.87468566  -2.14253355]\n",
      "system.dvect(12, 7) ->\n",
      "[ 1.23699232 -0.87468566 -2.14253355]\n"
     ]
    }
   ],
   "source": [
    "# Show simple position difference vector between atoms 7 and 12\n",
    "print(\"system.atoms.pos[7] - system.atoms.pos[12] ->\")\n",
    "print(system.atoms.pos[7] - system.atoms.pos[12])\n",
    "\n",
    "# Show shortest periodic distance vector between atoms 7 and 12\n",
    "print(\"system.dvect(12, 7) ->\")\n",
    "print(system.dvect(12, 7))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "system.dmag(34, system.atoms.pos) ->\n",
      "[ 5.24811395  3.03        2.62405697  4.28506709  5.02468656  6.77528597\n",
      "  6.6037319   2.62405697  7.42195392  2.62405697  5.24811395  5.02468656\n",
      "  3.03        6.77528597  5.02468656  6.06        5.02468656  6.77528597\n",
      "  5.02468656  6.6037319   4.28506709  7.87217092  9.09        7.87217092\n",
      "  6.06        4.28506709  5.02468656  3.03        5.02468656  4.28506709\n",
      "  5.02468656  5.02468656  6.77528597  2.62405697  0.          2.62405697\n",
      "  4.28506709  7.42195392  6.6037319   5.24811395  5.02468656  4.28506709\n",
      "  2.62405697  7.87217092  3.03        7.87217092  7.42195392  6.6037319\n",
      "  6.77528597  3.03        5.02468656  6.06        5.02468656  6.77528597\n",
      "  7.87217092  2.62405697  7.42195392  5.02468656  6.77528597  5.02468656\n",
      "  5.24811395  6.77528597  6.6037319   7.42195392  5.02468656  6.77528597\n",
      "  6.6037319   6.6037319   4.28506709  8.96286087 10.04937311  7.87217092\n",
      "  7.42195392  4.28506709  6.6037319   5.24811395  5.02468656  4.28506709\n",
      "  6.6037319   5.02468656  6.77528597  5.02468656  4.28506709  2.62405697\n",
      "  6.06        7.42195392  7.87217092  6.77528597  5.02468656  4.28506709\n",
      "  5.02468656  7.87217092  3.03        8.96286087  8.57013419  6.6037319 ]\n"
     ]
    }
   ],
   "source": [
    "# Compute the shortest periodic distance between atom 34 and all atoms\n",
    "print(\"system.dmag(34, system.atoms.pos) ->\")\n",
    "print(system.dmag(34, system.atoms.pos))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 6.2. neighborlist()\n",
    "\n",
    "The neighborlist() method returns a [NeighborList class](3.2._NeighborList_class.html) object for the system.\n",
    "\n",
    "Parameters\n",
    "\n",
    "- **cutoff** (*float, optional*) Radial cutoff distance for identifying neighbors.  Must be given if model is not given.\n",
    "        \n",
    "- **model** (*str or file-like object, optional*) Gives the file path or content to load.  If given, initialsize is the only other allowed parameter.\n",
    "        \n",
    "- **initialsize** (*int, optional*) The number of neighbor positions to initially assign to each atom. Default value is 20."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Computing neighbor list using cutoff of 2.727 angstrom\n"
     ]
    }
   ],
   "source": [
    "# Compute NeighborList for system\n",
    "cutoff = 0.90 *alat\n",
    "print('Computing neighbor list using cutoff of', cutoff, 'angstrom')\n",
    "neighbors = system.neighborlist(cutoff=cutoff)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "neighbors.coord ->\n",
      "[8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8\n",
      " 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8\n",
      " 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8]\n"
     ]
    }
   ],
   "source": [
    "# Show each atom's coordination\n",
    "print(\"neighbors.coord ->\")\n",
    "print(neighbors.coord)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "neighbors[4] ->\n",
      "[ 0  1  3  5  8 29 48 51]\n"
     ]
    }
   ],
   "source": [
    "# Show identified neighbors for atom 4\n",
    "print(\"neighbors[4] ->\")\n",
    "print(neighbors[4])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "np.linalg.norm(system.dvect(4, neighbors[4]), axis=1) ->\n",
      "[2.62405697 2.62405697 2.62405697 2.62405697 2.62405697 2.62405697\n",
      " 2.62405697 2.62405697]\n"
     ]
    }
   ],
   "source": [
    "# Show that all identified neighbors are within the cutoff of atom 4\n",
    "print(\"np.linalg.norm(system.dvect(4, neighbors[4]), axis=1) ->\")\n",
    "print(np.linalg.norm(system.dvect(4, neighbors[4]), axis=1))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 6.3. r0()\n",
    "\n",
    "*added version 1.3.2*\n",
    "\n",
    "The r0() method identifies the shortest interatomic spacing for the system.\n",
    "\n",
    "Parameters\n",
    "\n",
    "- **neighborlist** (*NeighborList, optional*) A pre-computed NeighborList for the system.  If not given, a new NeighborList will be used based on a cutoff distance related to the smallest dmag between atom 0 and the rest of the system's atoms."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2.624056973466846"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "system.r0()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7. model() and dump() <a id='section7'></a>\n",
    "\n",
    "*model() added version 1.2.7*\n",
    "\n",
    "A JSON/XML equivalent data model representation of the Systems object can be generated using the model() method. \n",
    "\n",
    "Parameters\n",
    "\n",
    "- __box_unit__ (*str, optional*) Length unit to use for the box. Default value is 'angstrom'.\n",
    "\n",
    "- __symbols__ (*list, optional*) List of atom-model symbols corresponding to the atom types.  If not given, will use system.symbols.\n",
    "\n",
    "- __prop_name__ (*list, optional*) The Atoms properties to include.  If neither prop_name nor prop_unit are given, all system properties will be included.\n",
    "\n",
    "- __unit__ (*list, optional*) Lists the units for each prop_name as stored in the table.  For a value of None, no conversion will be performed for that property.  For a value of 'scaled', the corresponding table values will be taken in box-scaled units.  If neither unit nor prop_units given, pos will be given in Angstroms and all other values will not be converted.\n",
    "\n",
    "- __prop_unit__ (*dict, optional*) Dictionary where the keys are the property keys to include, and the values are units to use. If neither unit nor prop_units given, pos will be given in Angstroms and all other values will not be converted.\n",
    "\n",
    "Returns\n",
    "        \n",
    "- (*DataModelDict.DataModelDict*) A JSON/XML data model for the current Systems object. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\"atomic-system\": {\"box\": {\"avect\": {\"value\": [14.843907841266057, 0.0, 0.0]}, \"bvect\": {\"value\": [0.0, 10.496227893867395, 0.0]}, \"cvect\": {\"value\": [0.0, 0.0, 8.570134187980956]}, \"origin\": {\"value\": [0.0, -10.496227893867395, -4.285067093990478]}}, \"periodic-boundary-condition\": [true, true, true], \"atom-type-symbol\": \"V\", \"atoms\": {\"natoms\": 96, \"property\": [{\"name\": \"atype\", \"data\": {\"value\": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]}}, {\"name\": \"pos\", \"data\": {\"value\": [6.184961600527525, -9.621542236045112, -2.1425335469952396, 2.473984640211009, -9.621542236045114, -8.881784197001252e-16, 3.7109769603165144, -10.496227893867395, -2.1425335469952396, 3.7109769603165144, -7.872170920400547, -2.142533546995239, 4.947969280422018, -8.746856578222829, -8.881784197001252e-16, 4.9479692804220194, -6.12279960475598, -8.881784197001252e-16, 6.184961600527524, -6.9974852625782615, -2.142533546995239, 0.0, -10.496227893867395, -4.285067093990478, 7.421953920633027, -7.872170920400547, -8.881784197001252e-16, 1.2369923201055044, -8.746856578222829, -2.1425335469952396, 1.2369923201055035, -6.12279960475598, -2.142533546995239, 2.473984640211009, -6.997485262578263, 0.0, 13.606915521160554, -9.621542236045112, -2.1425335469952396, 9.895938560844037, -9.621542236045114, -8.881784197001252e-16, 11.132930880949543, -10.496227893867395, -2.1425335469952396, 11.132930880949543, -7.872170920400547, -2.142533546995239, 12.369923201055046, -8.746856578222829, -8.881784197001252e-16, 12.369923201055048, -6.12279960475598, -8.881784197001252e-16, 13.606915521160554, -6.9974852625782615, -2.142533546995239, 7.421953920633029, -10.496227893867395, -4.285067093990478, 14.843907841266056, -7.872170920400547, -8.881784197001252e-16, 8.658946240738532, -8.746856578222829, -2.1425335469952396, 8.658946240738532, -6.12279960475598, -2.142533546995239, 9.895938560844037, -6.997485262578263, 0.0, 6.184961600527525, -4.373428289111415, -2.1425335469952396, 2.473984640211009, -4.373428289111415, -8.881784197001252e-16, 3.7109769603165144, -5.248113946933698, -2.1425335469952396, 3.7109769603165144, -2.624056973466849, -2.142533546995239, 4.947969280422018, -3.498742631289132, -8.881784197001252e-16, 4.9479692804220194, -0.8746856578222815, -8.881784197001252e-16, 6.184961600527524, -1.7493713156445647, -2.142533546995239, 0.0, -5.248113946933698, -4.285067093990478, 7.421953920633027, -2.624056973466849, -8.881784197001252e-16, 1.2369923201055044, -3.498742631289131, -2.1425335469952396, 1.2369923201055035, -0.8746856578222815, -2.142533546995239, 2.473984640211009, -1.7493713156445647, 0.0, 13.606915521160554, -4.373428289111415, -2.1425335469952396, 9.895938560844037, -4.373428289111415, -8.881784197001252e-16, 11.132930880949543, -5.248113946933698, -2.1425335469952396, 11.132930880949543, -2.624056973466849, -2.142533546995239, 12.369923201055046, -3.498742631289132, -8.881784197001252e-16, 12.369923201055048, -0.8746856578222815, -8.881784197001252e-16, 13.606915521160554, -1.7493713156445647, -2.142533546995239, 7.421953920633029, -5.248113946933698, -4.285067093990478, 14.843907841266056, -2.624056973466849, -8.881784197001252e-16, 8.658946240738532, -3.498742631289131, -2.1425335469952396, 8.658946240738532, -0.8746856578222815, -2.142533546995239, 9.895938560844037, -1.7493713156445647, 0.0, 6.184961600527525, -9.621542236045112, 2.1425335469952396, 2.473984640211009, -9.621542236045114, 4.2850670939904765, 3.7109769603165144, -10.496227893867395, 2.1425335469952396, 3.7109769603165144, -7.872170920400547, 2.1425335469952396, 4.947969280422018, -8.746856578222829, 4.2850670939904765, 4.9479692804220194, -6.12279960475598, 4.2850670939904765, 6.184961600527524, -6.9974852625782615, 2.1425335469952396, 0.0, -10.496227893867395, 0.0, 7.421953920633027, -7.872170920400547, 4.2850670939904765, 1.2369923201055044, -8.746856578222829, 2.1425335469952396, 1.2369923201055035, -6.12279960475598, 2.1425335469952396, 2.473984640211009, -6.997485262578263, 4.285067093990478, 13.606915521160554, -9.621542236045112, 2.1425335469952396, 9.895938560844037, -9.621542236045114, 4.2850670939904765, 11.132930880949543, -10.496227893867395, 2.1425335469952396, 11.132930880949543, -7.872170920400547, 2.1425335469952396, 12.369923201055046, -8.746856578222829, 4.2850670939904765, 12.369923201055048, -6.12279960475598, 4.2850670939904765, 13.606915521160554, -6.9974852625782615, 2.1425335469952396, 7.421953920633029, -10.496227893867395, 0.0, 14.843907841266056, -7.872170920400547, 4.2850670939904765, 8.658946240738532, -8.746856578222829, 2.1425335469952396, 8.658946240738532, -6.12279960475598, 2.1425335469952396, 9.895938560844037, -6.997485262578263, 4.285067093990478, 6.184961600527525, -4.373428289111415, 2.1425335469952396, 2.473984640211009, -4.373428289111415, 4.2850670939904765, 3.7109769603165144, -5.248113946933698, 2.1425335469952396, 3.7109769603165144, -2.624056973466849, 2.1425335469952396, 4.947969280422018, -3.498742631289132, 4.2850670939904765, 4.9479692804220194, -0.8746856578222815, 4.2850670939904765, 6.184961600527524, -1.7493713156445647, 2.1425335469952396, 0.0, -5.248113946933698, 0.0, 7.421953920633027, -2.624056973466849, 4.2850670939904765, 1.2369923201055044, -3.498742631289131, 2.1425335469952396, 1.2369923201055035, -0.8746856578222815, 2.1425335469952396, 2.473984640211009, -1.7493713156445647, 4.285067093990478, 13.606915521160554, -4.373428289111415, 2.1425335469952396, 9.895938560844037, -4.373428289111415, 4.2850670939904765, 11.132930880949543, -5.248113946933698, 2.1425335469952396, 11.132930880949543, -2.624056973466849, 2.1425335469952396, 12.369923201055046, -3.498742631289132, 4.2850670939904765, 12.369923201055048, -0.8746856578222815, 4.2850670939904765, 13.606915521160554, -1.7493713156445647, 2.1425335469952396, 7.421953920633029, -5.248113946933698, 0.0, 14.843907841266056, -2.624056973466849, 4.2850670939904765, 8.658946240738532, -3.498742631289131, 2.1425335469952396, 8.658946240738532, -0.8746856578222815, 2.1425335469952396, 9.895938560844037, -1.7493713156445647, 4.285067093990478], \"shape\": [96, 3], \"unit\": \"angstrom\"}}]}}}\n"
     ]
    }
   ],
   "source": [
    "model = system.model()\n",
    "print(model.json())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Any stored model information can then be reloaded in as a new System object by passing the 'model' parameter to the class initializer."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "avect =  [14.844,  0.000,  0.000]\n",
      "bvect =  [ 0.000, 10.496,  0.000]\n",
      "cvect =  [ 0.000,  0.000,  8.570]\n",
      "origin = [ 0.000, -10.496, -4.285]\n",
      "natoms = 96\n",
      "natypes = 1\n",
      "symbols = ('V',)\n",
      "pbc = [ True  True  True]\n",
      "per-atom properties = ['atype', 'pos']\n",
      "     id |   atype |  pos[0] |  pos[1] |  pos[2]\n",
      "      0 |       1 |   6.185 |  -9.622 |  -2.143\n",
      "      1 |       1 |   2.474 |  -9.622 |  -0.000\n",
      "      2 |       1 |   3.711 | -10.496 |  -2.143\n",
      "      3 |       1 |   3.711 |  -7.872 |  -2.143\n",
      "      4 |       1 |   4.948 |  -8.747 |  -0.000\n",
      "      5 |       1 |   4.948 |  -6.123 |  -0.000\n",
      "      6 |       1 |   6.185 |  -6.997 |  -2.143\n",
      "      7 |       1 |   0.000 | -10.496 |  -4.285\n",
      "      8 |       1 |   7.422 |  -7.872 |  -0.000\n",
      "      9 |       1 |   1.237 |  -8.747 |  -2.143\n",
      "     10 |       1 |   1.237 |  -6.123 |  -2.143\n",
      "     11 |       1 |   2.474 |  -6.997 |   0.000\n",
      "     12 |       1 |  13.607 |  -9.622 |  -2.143\n",
      "     13 |       1 |   9.896 |  -9.622 |  -0.000\n",
      "     14 |       1 |  11.133 | -10.496 |  -2.143\n",
      "     15 |       1 |  11.133 |  -7.872 |  -2.143\n",
      "     16 |       1 |  12.370 |  -8.747 |  -0.000\n",
      "     17 |       1 |  12.370 |  -6.123 |  -0.000\n",
      "     18 |       1 |  13.607 |  -6.997 |  -2.143\n",
      "     19 |       1 |   7.422 | -10.496 |  -4.285\n",
      "     20 |       1 |  14.844 |  -7.872 |  -0.000\n",
      "     21 |       1 |   8.659 |  -8.747 |  -2.143\n",
      "     22 |       1 |   8.659 |  -6.123 |  -2.143\n",
      "     23 |       1 |   9.896 |  -6.997 |   0.000\n",
      "     24 |       1 |   6.185 |  -4.373 |  -2.143\n",
      "     25 |       1 |   2.474 |  -4.373 |  -0.000\n",
      "     26 |       1 |   3.711 |  -5.248 |  -2.143\n",
      "     27 |       1 |   3.711 |  -2.624 |  -2.143\n",
      "     28 |       1 |   4.948 |  -3.499 |  -0.000\n",
      "     29 |       1 |   4.948 |  -0.875 |  -0.000\n",
      "     30 |       1 |   6.185 |  -1.749 |  -2.143\n",
      "     31 |       1 |   0.000 |  -5.248 |  -4.285\n",
      "     32 |       1 |   7.422 |  -2.624 |  -0.000\n",
      "     33 |       1 |   1.237 |  -3.499 |  -2.143\n",
      "     34 |       1 |   1.237 |  -0.875 |  -2.143\n",
      "     35 |       1 |   2.474 |  -1.749 |   0.000\n",
      "     36 |       1 |  13.607 |  -4.373 |  -2.143\n",
      "     37 |       1 |   9.896 |  -4.373 |  -0.000\n",
      "     38 |       1 |  11.133 |  -5.248 |  -2.143\n",
      "     39 |       1 |  11.133 |  -2.624 |  -2.143\n",
      "     40 |       1 |  12.370 |  -3.499 |  -0.000\n",
      "     41 |       1 |  12.370 |  -0.875 |  -0.000\n",
      "     42 |       1 |  13.607 |  -1.749 |  -2.143\n",
      "     43 |       1 |   7.422 |  -5.248 |  -4.285\n",
      "     44 |       1 |  14.844 |  -2.624 |  -0.000\n",
      "     45 |       1 |   8.659 |  -3.499 |  -2.143\n",
      "     46 |       1 |   8.659 |  -0.875 |  -2.143\n",
      "     47 |       1 |   9.896 |  -1.749 |   0.000\n",
      "     48 |       1 |   6.185 |  -9.622 |   2.143\n",
      "     49 |       1 |   2.474 |  -9.622 |   4.285\n",
      "     50 |       1 |   3.711 | -10.496 |   2.143\n",
      "     51 |       1 |   3.711 |  -7.872 |   2.143\n",
      "     52 |       1 |   4.948 |  -8.747 |   4.285\n",
      "     53 |       1 |   4.948 |  -6.123 |   4.285\n",
      "     54 |       1 |   6.185 |  -6.997 |   2.143\n",
      "     55 |       1 |   0.000 | -10.496 |   0.000\n",
      "     56 |       1 |   7.422 |  -7.872 |   4.285\n",
      "     57 |       1 |   1.237 |  -8.747 |   2.143\n",
      "     58 |       1 |   1.237 |  -6.123 |   2.143\n",
      "     59 |       1 |   2.474 |  -6.997 |   4.285\n",
      "     60 |       1 |  13.607 |  -9.622 |   2.143\n",
      "     61 |       1 |   9.896 |  -9.622 |   4.285\n",
      "     62 |       1 |  11.133 | -10.496 |   2.143\n",
      "     63 |       1 |  11.133 |  -7.872 |   2.143\n",
      "     64 |       1 |  12.370 |  -8.747 |   4.285\n",
      "     65 |       1 |  12.370 |  -6.123 |   4.285\n",
      "     66 |       1 |  13.607 |  -6.997 |   2.143\n",
      "     67 |       1 |   7.422 | -10.496 |   0.000\n",
      "     68 |       1 |  14.844 |  -7.872 |   4.285\n",
      "     69 |       1 |   8.659 |  -8.747 |   2.143\n",
      "     70 |       1 |   8.659 |  -6.123 |   2.143\n",
      "     71 |       1 |   9.896 |  -6.997 |   4.285\n",
      "     72 |       1 |   6.185 |  -4.373 |   2.143\n",
      "     73 |       1 |   2.474 |  -4.373 |   4.285\n",
      "     74 |       1 |   3.711 |  -5.248 |   2.143\n",
      "     75 |       1 |   3.711 |  -2.624 |   2.143\n",
      "     76 |       1 |   4.948 |  -3.499 |   4.285\n",
      "     77 |       1 |   4.948 |  -0.875 |   4.285\n",
      "     78 |       1 |   6.185 |  -1.749 |   2.143\n",
      "     79 |       1 |   0.000 |  -5.248 |   0.000\n",
      "     80 |       1 |   7.422 |  -2.624 |   4.285\n",
      "     81 |       1 |   1.237 |  -3.499 |   2.143\n",
      "     82 |       1 |   1.237 |  -0.875 |   2.143\n",
      "     83 |       1 |   2.474 |  -1.749 |   4.285\n",
      "     84 |       1 |  13.607 |  -4.373 |   2.143\n",
      "     85 |       1 |   9.896 |  -4.373 |   4.285\n",
      "     86 |       1 |  11.133 |  -5.248 |   2.143\n",
      "     87 |       1 |  11.133 |  -2.624 |   2.143\n",
      "     88 |       1 |  12.370 |  -3.499 |   4.285\n",
      "     89 |       1 |  12.370 |  -0.875 |   4.285\n",
      "     90 |       1 |  13.607 |  -1.749 |   2.143\n",
      "     91 |       1 |   7.422 |  -5.248 |   0.000\n",
      "     92 |       1 |  14.844 |  -2.624 |   4.285\n",
      "     93 |       1 |   8.659 |  -3.499 |   2.143\n",
      "     94 |       1 |   8.659 |  -0.875 |   2.143\n",
      "     95 |       1 |   9.896 |  -1.749 |   4.285\n"
     ]
    }
   ],
   "source": [
    "print(am.System(model=model))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The system can also be exported to a number of other formats using the dump() method. \n",
    "\n",
    "See the [1.4. Load and dump conversions Jupyter Notebook](1.4._Load_and_dump_conversions.html) for more detailed information on the different styles and options."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "1.0000000000000e+00\n",
      "1.4843907841266e+01 0.0000000000000e+00 0.0000000000000e+00\n",
      "0.0000000000000e+00 1.0496227893867e+01 0.0000000000000e+00\n",
      "0.0000000000000e+00 0.0000000000000e+00 8.5701341879810e+00\n",
      "V\n",
      "96 \n",
      "direct\n",
      "4.1666666666667e-01 8.3333333333333e-02 2.5000000000000e-01\n",
      "1.6666666666667e-01 8.3333333333333e-02 5.0000000000000e-01\n",
      "2.5000000000000e-01 0.0000000000000e+00 2.5000000000000e-01\n",
      "2.5000000000000e-01 2.5000000000000e-01 2.5000000000000e-01\n",
      "3.3333333333333e-01 1.6666666666667e-01 5.0000000000000e-01\n",
      "3.3333333333333e-01 4.1666666666667e-01 5.0000000000000e-01\n",
      "4.1666666666667e-01 3.3333333333333e-01 2.5000000000000e-01\n",
      "0.0000000000000e+00 0.0000000000000e+00 0.0000000000000e+00\n",
      "5.0000000000000e-01 2.5000000000000e-01 5.0000000000000e-01\n",
      "8.3333333333333e-02 1.6666666666667e-01 2.5000000000000e-01\n",
      "8.3333333333333e-02 4.1666666666667e-01 2.5000000000000e-01\n",
      "1.6666666666667e-01 3.3333333333333e-01 5.0000000000000e-01\n",
      "9.1666666666667e-01 8.3333333333333e-02 2.5000000000000e-01\n",
      "6.6666666666667e-01 8.3333333333333e-02 5.0000000000000e-01\n",
      "7.5000000000000e-01 0.0000000000000e+00 2.5000000000000e-01\n",
      "7.5000000000000e-01 2.5000000000000e-01 2.5000000000000e-01\n",
      "8.3333333333333e-01 1.6666666666667e-01 5.0000000000000e-01\n",
      "8.3333333333333e-01 4.1666666666667e-01 5.0000000000000e-01\n",
      "9.1666666666667e-01 3.3333333333333e-01 2.5000000000000e-01\n",
      "5.0000000000000e-01 0.0000000000000e+00 0.0000000000000e+00\n",
      "1.0000000000000e+00 2.5000000000000e-01 5.0000000000000e-01\n",
      "5.8333333333333e-01 1.6666666666667e-01 2.5000000000000e-01\n",
      "5.8333333333333e-01 4.1666666666667e-01 2.5000000000000e-01\n",
      "6.6666666666667e-01 3.3333333333333e-01 5.0000000000000e-01\n",
      "4.1666666666667e-01 5.8333333333333e-01 2.5000000000000e-01\n",
      "1.6666666666667e-01 5.8333333333333e-01 5.0000000000000e-01\n",
      "2.5000000000000e-01 5.0000000000000e-01 2.5000000000000e-01\n",
      "2.5000000000000e-01 7.5000000000000e-01 2.5000000000000e-01\n",
      "3.3333333333333e-01 6.6666666666667e-01 5.0000000000000e-01\n",
      "3.3333333333333e-01 9.1666666666667e-01 5.0000000000000e-01\n",
      "4.1666666666667e-01 8.3333333333333e-01 2.5000000000000e-01\n",
      "0.0000000000000e+00 5.0000000000000e-01 0.0000000000000e+00\n",
      "5.0000000000000e-01 7.5000000000000e-01 5.0000000000000e-01\n",
      "8.3333333333333e-02 6.6666666666667e-01 2.5000000000000e-01\n",
      "8.3333333333333e-02 9.1666666666667e-01 2.5000000000000e-01\n",
      "1.6666666666667e-01 8.3333333333333e-01 5.0000000000000e-01\n",
      "9.1666666666667e-01 5.8333333333333e-01 2.5000000000000e-01\n",
      "6.6666666666667e-01 5.8333333333333e-01 5.0000000000000e-01\n",
      "7.5000000000000e-01 5.0000000000000e-01 2.5000000000000e-01\n",
      "7.5000000000000e-01 7.5000000000000e-01 2.5000000000000e-01\n",
      "8.3333333333333e-01 6.6666666666667e-01 5.0000000000000e-01\n",
      "8.3333333333333e-01 9.1666666666667e-01 5.0000000000000e-01\n",
      "9.1666666666667e-01 8.3333333333333e-01 2.5000000000000e-01\n",
      "5.0000000000000e-01 5.0000000000000e-01 0.0000000000000e+00\n",
      "1.0000000000000e+00 7.5000000000000e-01 5.0000000000000e-01\n",
      "5.8333333333333e-01 6.6666666666667e-01 2.5000000000000e-01\n",
      "5.8333333333333e-01 9.1666666666667e-01 2.5000000000000e-01\n",
      "6.6666666666667e-01 8.3333333333333e-01 5.0000000000000e-01\n",
      "4.1666666666667e-01 8.3333333333333e-02 7.5000000000000e-01\n",
      "1.6666666666667e-01 8.3333333333333e-02 1.0000000000000e+00\n",
      "2.5000000000000e-01 0.0000000000000e+00 7.5000000000000e-01\n",
      "2.5000000000000e-01 2.5000000000000e-01 7.5000000000000e-01\n",
      "3.3333333333333e-01 1.6666666666667e-01 1.0000000000000e+00\n",
      "3.3333333333333e-01 4.1666666666667e-01 1.0000000000000e+00\n",
      "4.1666666666667e-01 3.3333333333333e-01 7.5000000000000e-01\n",
      "0.0000000000000e+00 0.0000000000000e+00 5.0000000000000e-01\n",
      "5.0000000000000e-01 2.5000000000000e-01 1.0000000000000e+00\n",
      "8.3333333333333e-02 1.6666666666667e-01 7.5000000000000e-01\n",
      "8.3333333333333e-02 4.1666666666667e-01 7.5000000000000e-01\n",
      "1.6666666666667e-01 3.3333333333333e-01 1.0000000000000e+00\n",
      "9.1666666666667e-01 8.3333333333333e-02 7.5000000000000e-01\n",
      "6.6666666666667e-01 8.3333333333333e-02 1.0000000000000e+00\n",
      "7.5000000000000e-01 0.0000000000000e+00 7.5000000000000e-01\n",
      "7.5000000000000e-01 2.5000000000000e-01 7.5000000000000e-01\n",
      "8.3333333333333e-01 1.6666666666667e-01 1.0000000000000e+00\n",
      "8.3333333333333e-01 4.1666666666667e-01 1.0000000000000e+00\n",
      "9.1666666666667e-01 3.3333333333333e-01 7.5000000000000e-01\n",
      "5.0000000000000e-01 0.0000000000000e+00 5.0000000000000e-01\n",
      "1.0000000000000e+00 2.5000000000000e-01 1.0000000000000e+00\n",
      "5.8333333333333e-01 1.6666666666667e-01 7.5000000000000e-01\n",
      "5.8333333333333e-01 4.1666666666667e-01 7.5000000000000e-01\n",
      "6.6666666666667e-01 3.3333333333333e-01 1.0000000000000e+00\n",
      "4.1666666666667e-01 5.8333333333333e-01 7.5000000000000e-01\n",
      "1.6666666666667e-01 5.8333333333333e-01 1.0000000000000e+00\n",
      "2.5000000000000e-01 5.0000000000000e-01 7.5000000000000e-01\n",
      "2.5000000000000e-01 7.5000000000000e-01 7.5000000000000e-01\n",
      "3.3333333333333e-01 6.6666666666667e-01 1.0000000000000e+00\n",
      "3.3333333333333e-01 9.1666666666667e-01 1.0000000000000e+00\n",
      "4.1666666666667e-01 8.3333333333333e-01 7.5000000000000e-01\n",
      "0.0000000000000e+00 5.0000000000000e-01 5.0000000000000e-01\n",
      "5.0000000000000e-01 7.5000000000000e-01 1.0000000000000e+00\n",
      "8.3333333333333e-02 6.6666666666667e-01 7.5000000000000e-01\n",
      "8.3333333333333e-02 9.1666666666667e-01 7.5000000000000e-01\n",
      "1.6666666666667e-01 8.3333333333333e-01 1.0000000000000e+00\n",
      "9.1666666666667e-01 5.8333333333333e-01 7.5000000000000e-01\n",
      "6.6666666666667e-01 5.8333333333333e-01 1.0000000000000e+00\n",
      "7.5000000000000e-01 5.0000000000000e-01 7.5000000000000e-01\n",
      "7.5000000000000e-01 7.5000000000000e-01 7.5000000000000e-01\n",
      "8.3333333333333e-01 6.6666666666667e-01 1.0000000000000e+00\n",
      "8.3333333333333e-01 9.1666666666667e-01 1.0000000000000e+00\n",
      "9.1666666666667e-01 8.3333333333333e-01 7.5000000000000e-01\n",
      "5.0000000000000e-01 5.0000000000000e-01 5.0000000000000e-01\n",
      "1.0000000000000e+00 7.5000000000000e-01 1.0000000000000e+00\n",
      "5.8333333333333e-01 6.6666666666667e-01 7.5000000000000e-01\n",
      "5.8333333333333e-01 9.1666666666667e-01 7.5000000000000e-01\n",
      "6.6666666666667e-01 8.3333333333333e-01 1.0000000000000e+00\n"
     ]
    }
   ],
   "source": [
    "poscar = system.dump('poscar')\n",
    "print(poscar)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "  "
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
